<template>
	<view>
		<!-- 浏览器 -->
		<web-view :src="url" class="web"></web-view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		CONFIG
	} from '../../utils/config'
	import {
		userStore
	} from '../../store/userStore'

	let store = userStore()
	let url = ref("")

	onLoad((data) => {
		let type = data.type
		console.log(type)
		if (type == 1) {
			url.value = `https://m.amap.com/navi/?dest=${store.currentPos.longitude},${store.currentPos.latitude}&destName=我的位置&hideRouteIcon=1&key==${CONFIG.gaode_key}&jscode=${CONFIG.gaode_skey}
		`
			uni.setNavigationBarTitle({
				title: "我的位置"
			})
		} else if (type == 2) {
			let latitude = data.latitude
			let longitude = data.longitude
			url.value =
				`https://m.amap.com/navi/?start=${store.currentPos.longitude},${store.currentPos.latitude}&dest=${latitude},${longitude}&destName=${data.name}&key=${CONFIG.gaode_key}&jscode=${CONFIG.gaode_skey}`
			uni.setNavigationBarTitle({
				title: "到" + data.name + "的路径"
			})
		}

	})
</script>

<style>

</style>